import React from 'react'
import { View, StyleSheet, Text } from 'react-native'
import { ScaleS, ScaleT } from 'src/utils/ScreenUtil'
import PropTypes from 'prop-types'
import CustomButton from '../button/CustomButton'
import CheckButton from '../check-button/index'

export default function CheckDeleteView (props) {
  const { checked, onCheckedPress, checkedParams, style, highlight, onDeletePress, deleteParams } = props
  const onCheckedClick = (params) => {
    onCheckedPress && onCheckedPress(params)
  }
  const onDeleteClick = (params) => {
    onDeletePress && onDeletePress(params)
  }
  return (
    <View style={[styles.bottomSelectView, style]}>
      <CheckButton checked={checked} onPress={onCheckedClick} params={checkedParams}/>
      <Text style={styles.allSelectedText}>全选</Text>
      <CustomButton
        style={[styles.deleteView, { backgroundColor: highlight ? '#000000' : '#EBEBEB' }]}
        onPress={onDeleteClick}
        params={deleteParams}>
        <Text style={[styles.deleteText, { color: highlight ? '#FFFFFF' : '#999999' }]}>删除</Text>
      </CustomButton>
    </View>
  )
}
CheckDeleteView.defaultProps = {
  checked: false,
  highlight: false
}
CheckDeleteView.propTypes = {
  checked: PropTypes.bool.isRequired,
  onCheckedPress: PropTypes.func.isRequired,
  onDeletePress: PropTypes.func.isRequired,
  checkedParams: PropTypes.object,
  deleteParams: PropTypes.object,
  style: PropTypes.object,
  highlight: PropTypes.bool
}

const styles = StyleSheet.create({
  bottomSelectView: {
    height: ScaleS(56),
    flexDirection: 'row',
    alignItems: 'center',
    paddingHorizontal: ScaleS(20)
  },
  allSelectedText: {
    color: '#444444',
    fontSize: ScaleT(15),
    fontWeight: '400',
    marginLeft: ScaleS(11),
    flex: 1
  },
  deleteView: {
    width: ScaleS(72),
    height: ScaleS(40),
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#000000',
    borderRadius: ScaleS(4)
  },
  deleteText: {
    color: '#FFFFFF',
    fontSize: ScaleT(15),
    fontWeight: '400'
  }
})
